package dreamCookGame.conveyorBeltMiniGame;
import dreamCookGame.Item;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImage;

import javax.imageio.ImageIO;

public class Box extends Item {
	
	boolean _active;
	int _steps;
	public Point[] _bottomCorners;
	AffineTransformOp _transform;
	double _transformIndex;
	Graphics2D _g2;
	String _value;
	
	public Box(String[] boxImages, int x, int y, String value) {
		super("bag", boxImages, x, y, null, null, null, false, null);
		_bottomCorners = new Point[2];
		_bottomCorners[0] = new Point();
		_bottomCorners[1] = new Point();
		_active = false;
		_steps = 0;
		_value = value;
	}
	
	public void shift() {
		if(_active) {
				_steps++;
				this.updatePosition(_x, _y += 5);
				getBottomCorners();
			}
		
	}
	
	public void scaleUp(double increment)
	{
		/*
		_imgG2 = this._img.createGraphics();
		_transform = new AffineTransformOp(AffineTransform.getScaleInstance(increment, increment), AffineTransformOp.TYPE_BILINEAR);
		BufferedImage temp = new BufferedImage(_img.getWidth(), _img.getHeight(), BufferedImage.TYPE_INT_ARGB);
		//BufferedImage temp = this._img.c
		_transform.filter(this._img, null);
		//this._img = temp;
		//_imgG2.drawImage(this._img, 100, 100, null);
		
		
		//_imgG2.drawRenderedImage(_img, _transform);
		//_imgG2.transform(_transform);*/
		/*
		_g2 = this._img.createGraphics();
		
		AffineTransform tempTransform = _g2.getTransform();

		//Float scaleValue = _currentScene._characters[i].getScale();
		int xShift = _x;
		int yShift = _y;

		_g2.translate( xShift, yShift);
		_g2.scale(increment, increment);
		_g2.translate( -xShift, -yShift);

		_g2.drawImage(this._itemsBack[i]._img, 0, 0, this);

		_g2.setTransform(tempTransform);

		//-Jonathan :)*/
	}
	
	public void getBottomCorners() {
		Rectangle rectangle = this._itemButton._boundingBox.getBounds();
		double width = rectangle.getWidth();
		double height = rectangle.getHeight();
		_bottomCorners[0].setLocation(rectangle.x, rectangle.y + height);
		_bottomCorners[1].setLocation(rectangle.x + width, rectangle.y + height);
	}
	
	public void stop() {
		this.updatePosition(800, 800);
		_active = false;
	}
	
	public void start() {
		_active = true;
		_steps = 0;
	}
	
	
	
	
}
